import axios from "axios";

export const uploadImage = async (file)=>{
  let form = new FormData();
  form.append('file',file)
  return new Promise((resolve,reject)=>{
    fetch('https://service-eybsd6ln-1307637143.sh.apigw.tencentcs.com/release/upload',{
      method:'POST',
      body:form,
    }).then(async e=>{
      if (e.ok){
        let resp = await e.json();
        if (resp.success) {
          resolve(resp)
        }
      }else {
        console.error(e)
        resolve({success:false,message:"网络错误"})
      }

    }).catch(e=>{
      resolve({success:false,message:"网络错误"})
      console.error(e)
    })
  })
}